<template>
    <el-tree   :data="catalogs"  :props="catalogProps"

        :load="loadCatalogTreeNode"
        @node-click="onObjectNodeClick"
          lazy
        >

        </el-tree>
</template>

<script>
    import Vue from 'vue';
    import {catalogApi} from '../apis/catalog.js';

    import CollapseTransition from 'element-ui/lib/transitions/collapse-transition';
    Vue.component("el-collapse-transition", CollapseTransition)

    import 'element-ui/lib/theme-default/tree.css';
    //import 'element-ui/lib/theme-default/checkbox.css';
    import {Tree /*,Checkbox*/} from 'element-ui'
	Vue.component(Tree.name, Tree)
   // Vue.component(Checkbox.name, Checkbox)

  
    


    export default {
        data () {
            return {


				catalogs :[
				   {
                      id :"0",
                      name :"数据库"
				   }
				],

				catalogProps:{
                   label: 'NAME',
                   children: 'children'
                }
            }
        },
        mounted() {

        },
        watch: {
            '$route' (to, from) {
                // 对路由变化作出响应...

            },
            '$vnode' (to, from) {

            }
        },
        methods:{
            loadCatalogTreeNode(node, resolve){


                    catalogApi.getCatalogChildren(node.id ,node.data.TYPE,node.data.SCEMA).then(
                         ret =>{
                              resolve(ret)
                         }
                    );
		     },
		     onObjectNodeClick(obj ,node ,self){
			        console.log(node)
			        this.$vnode.data.attrs.onObjectNodeClick(obj ,node ,self)
			 }
        }
    }

</script>


<style>
</style>